const axios = {}

axios.get = (url, data = {}, config = {
  header: { 'content-type': 'application/x-www-form-urlencoded' },}) => {
  return new Promise((resolve, reject) => {
    uni.request({
      url: url,
      method: 'GET',
      data: {
        ...data
      },
      ...config,
      success: res => {
        resolve(res)
      },
      fail: err => {
        reject(err)
      }
    })
  })
}


axios.post = (url, data = {}, config = {
  header: { 'content-type': 'application/x-www-form-urlencoded' },}) => {

  return new Promise((resolve, reject) => {
    uni.request({
      url: url,
      method: 'POST',
      data: {
        ...data
      },
      ...config,
      success: res => {
        resolve(res)
      },
      fail: err => {
        reject(err)
      }
    })
  })
}


export default axios
